#ifndef _BUOLA_GL_CVBO_H_
#define _BUOLA_GL_CVBO_H_

#include <buola/gl/cbuffer.h>
#include <buola/gl/cvbomap.h>

namespace buola { namespace gl {

class CVBO : public CBuffer
{
public:
    CVBO()=default;
    CVBO(const CVBO&)=delete;
    CVBO(CVBO&&)=default;
    ~CVBO()=default;
    CVBO &operator=(const CVBO&)=delete;
    CVBO &operator=(CVBO&&)=default;

private:
    using CBuffer::Create;

public:
    void Create(GLuint pSize)
    {
        Create(GL_ARRAY_BUFFER,pSize);
    }

    template<typename tType>
    CVBOMap<tType> Map(GLenum pAccess=GL_WRITE_ONLY)
    {
        Bind();
        return CVBOMap<tType>((tType*)glMapBuffer(Target(),pAccess),size());
    }

    template<typename tType>
    void Unmap(CVBOMap<tType> &pMap)
    {
        Bind();
        pMap.Release();
        glUnmapBuffer(Target());
    }
};

/*namespace gl*/ } /*namespace buola*/ }

#endif
